package com.example.mydataapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.android.material.navigation.NavigationView;

import java.util.Map;

public class MainActivity extends AppCompatActivity  {
    private NavHostFragment navHostFragment;
    private NavController navController;
    private AppBarConfiguration appBarConfiguration;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    /*    initView();
        Map<String,String> userInfo=Sharedpre.getUserInfo(this);
        if(userInfo!=null)
        {
            etNumber.setText(userInfo.get("number"));
            etpassword.setText(userInfo.get("password"));
        }*/
        navHostFragment =
                (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
        navController = navHostFragment.getNavController();
        appBarConfiguration =
                new AppBarConfiguration.Builder(R.id.Home)
                        .setOpenableLayout(findViewById(R.id.drawlayout))
                        .build();
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController((NavigationView)findViewById(R.id.nav_view),navController);
    }
   /* private void initView(){
        etNumber=(EditText)findViewById(R.id.et_number);
        etpassword=(EditText)findViewById(R.id.et_password);
        btn=(Button)findViewById(R.id.bo_ne);
        btn.setOnClickListener((View.OnClickListener) this);
    }*/
    @Override
    public boolean onSupportNavigateUp() {
        return NavigationUI.navigateUp(navController,appBarConfiguration)||super.onSupportNavigateUp();
    }


    /*public void onClick(View view){
        String number=etNumber.getText().toString().trim();
        String password=etpassword.getText().toString();
        if (TextUtils.isEmpty(number)){
            Toast.makeText(this,"请输入QQ账号",Toast.LENGTH_SHORT).show();
            return;
        }
     if (TextUtils.isEmpty(password)){
         Toast.makeText(this,"请输入QQ密码",Toast.LENGTH_SHORT).show();
         return;
     }
     Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
     boolean isSaveSuccess= Sharedpre.saveUserInfo(this,number,password);
     if (isSaveSuccess)
     {
         Toast.makeText(this,"保存成功",Toast.LENGTH_SHORT).show();
     }else {
         Toast.makeText(this,"保存失败",Toast.LENGTH_SHORT).show();
     }
 }*/
}